package com.wuchao.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wuchao.entity.Entry;
import com.wuchao.mapper.EntryMapper;
import com.wuchao.service.EntryService;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author wuchao66
 * @Date 2023/10/16 11:24
 * @PackageName:com.wuchao.service.impl
 * @ClassName: EntryServiceImpl
 * @Description: TODO
 * @Param
 * @Version 1.0
 */
@Service
//@Scope("prototype")
public class EntryServiceImpl implements EntryService {
    //容器注入ioc
    @Resource

    private EntryMapper entryMapper;

    @Override
    public int loadby(String title, String summary) {
        return  entryMapper.loadby(title, summary);

    }

    @Override
    public List<Entry> findEntryByTitle(String title) {
        return entryMapper.findEntryByTitle(title);
    }

    @Override
    public List<Entry> findEntryById(int id) {
        return entryMapper.findEntryById(id);
    }

    //    @Resource
//    private   EntryService entryService;//mvc吊塔
    @Override
    public List<Entry> findEntryByCONCATTitle1(String title) {

        return entryMapper.findEntryByCONCATTitle1(title);
    }

    @Override
    public PageInfo<Entry> findEntryAndCategoryByCONCATTitleByCategoryId(int currentPage, int pageSize, String title, int categoryId) {
        PageHelper.startPage(currentPage,pageSize);
        return new PageInfo<Entry>(  entryMapper.findEntryAndCategoryByCONCATTitleByCategoryId(title, categoryId));
    }

    @Override
    public int addEntryByEntry(Entry entry) {
        return entryMapper.addEntryByEntry(entry);
    }
}
